package com.onedec.page.controller;

import com.onedec.page.feign.AdminClient;
import com.onedec.utils.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *登录方法调用
 */
@RestController
public class AdminController {
    @Autowired
    private AdminClient adminClient;

    /**
     * 登录
     * @param empUsername
     * @param empPwd
     * @return
     */
    @PostMapping("login")
    public ResponseEntity findBylogin(@RequestParam  String empUsername,@RequestParam String empPwd){
        ResponseEntity login = adminClient.findBylogin(empUsername, empPwd);
        System.out.println("打印信息"+login);
        return login;
    }

    /**
     * 发邮件
     * @param email
     * @param i
     * @return
     */
    @GetMapping("email")
    public ResponseEntity findByemail(@RequestParam String email, @RequestParam int i){
        ResponseEntity byemail = adminClient.findByemail(email, i);
        return byemail;
    }

    /**
     * 修改密码
     * @param empPwd
     * @param empPwd1
     * @return
     */
    @PostMapping("updatePwd")
    public ResponseEntity updatePwd(@RequestParam String empPwd,@RequestParam String empPwd1){
        ResponseEntity responseEntity = adminClient.updatePwd(empPwd, empPwd1);
        return responseEntity;
    }
    /**
     * 查询所有用户
     */
    @GetMapping("selectAllEmp")
    public ResponseEntity selectAllEmp(){
        ResponseEntity responseEntity = adminClient.selectAllEmp();
        return responseEntity;
    }
}
